package test.java.mock;

import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

import main.java.maziacs.IBoard;
import main.java.maziacs.ITile;
import main.java.maziacs.Path;
import main.java.maziacs.Tile;
import main.java.maziacs.counters.Treasure;
import main.java.maziacs.squares.Circle;
import main.java.maziacs.squares.EndSquare;
import main.java.maziacs.squares.Gray;
import main.java.maziacs.squares.Square;
import main.java.maziacs.squares.StartSquare;
import main.java.maziacs.squares.White;


public class MockTile implements ITile {
	public List<String> tileAux;
	public List<String> starTile;
	public List<String> squares2;
	private Circle circle;
	private IBoard board;
	Square[][] squares;
	private Map<ITile, List<Integer>> adjacentTiles;
	
	public MockTile(List<String> list){
		if(list==null)
			throw new IllegalArgumentException();
		squares2=list;
	}
	public MockTile(List<String> list, MockBoard b){
		if(list==null)
			throw new IllegalArgumentException();
		squares2=list;
		this.setBoard(b);
	}
	
	public MockTile(IBoard b, String s){
		board=b;
		circle=null;
		squares=new Square[3][3];
		List<String> v = new LinkedList<String>();
		StringTokenizer st = new StringTokenizer(s, " ");
		while (st.hasMoreTokens())
			v.add(st.nextToken());
		
		setName(v.remove(0));
		setSquares(v);
		adjacentTiles=new LinkedHashMap<ITile, List<Integer>>();
	}
	public static List<String> loadStarTile(){
        //G W G W S W G W G
        List<String> l = new LinkedList<String>();
        l.add("G");
        l.add("W");
        l.add("G");
        l.add("W");
        l.add("S");
        l.add("W");
        l.add("G");
        l.add("W");
        l.add("G");
        return l;
	}
	public static List<String> load9Tile(){
        //TILE9 G G G W W G G W G
        List<String> l = new LinkedList<String>();
        l.add("G");
        l.add("G");
        l.add("G");
        l.add("W");
        l.add("W");
        l.add("G");
        l.add("G");
        l.add("W");
        l.add("G");
        return l;
	}
	public static List<String> load5Tile(){
        //TILE5 G W G W W C G W G
        List<String> l = new LinkedList<String>();
        l.add("G");
        l.add("W");
        l.add("G");
        l.add("W");
        l.add("W");
        l.add("C");
        l.add("G");
        l.add("W");
        l.add("G");
        return l;
	}
	public static List<String> load21Tile(){
        //TILE21 G W G G W G G W G
        List<String> l = new LinkedList<String>();
        l.add("G");
        l.add("W");
        l.add("G");
        l.add("G");
        l.add("W");
        l.add("G");
        l.add("G");
        l.add("W");
        l.add("G");
        return l;
	}
	public static List<String> loadEndTile(){
        //ENDTILE G W G G E G G G G
        List<String> l = new LinkedList<String>();
        l.add("G");
        l.add("W");
        l.add("G");
        l.add("G");
        l.add("E");
        l.add("G");
        l.add("G");
        l.add("G");
        l.add("G");
        return l;
}

	//@Override
	public void addAdjacentTile(Tile tile, Integer i, Integer j) {
		// TODO Auto-generated method stub

	}

	@Override
	public boolean containsCircle() {
		return squares2.contains("C");
	}

	@Override
	public boolean containsCounter() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public Boolean containsTreasure() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Map<ITile, List<Integer>> getAdjacentTiles() {
		// TODO Auto-generated method stub
		return adjacentTiles;
	}

	@Override
	public IBoard getBoard() {
		// TODO Auto-generated method stub
		return board;
	}

	@Override
	public String getName() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Path getPath() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Integer getPositionI() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Integer getPositionJ() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Square[][] getSquares() {
		// TODO Auto-generated method stub
		return squares;
	}

	@Override
	public int getTotalNumberTiles() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public Treasure getTreasure() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getTypeSquare() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean isPartOfPath() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void setAdjacentTiles(Map<ITile, List<Integer>> adjacentTiles) {
		// TODO Auto-generated method stub

	}

	@Override
	public void setBoard(IBoard board) {
		// TODO Auto-generated method stub

	}

	@Override
	public void setName(String name) {
		// TODO Auto-generated method stub

	}

	@Override
	public void setPath(Path path) {
		// TODO Auto-generated method stub

	}

	@Override
	public void setPositionI(Integer positionI) {
		// TODO Auto-generated method stub

	}

	@Override
	public void setPositionJ(Integer positionJ) {
		// TODO Auto-generated method stub

	}

	@Override
	public void setSquares(List<String> squares) {
		String s;
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				s=squares.remove(0);
				if(s.equals("W")){
					this.squares[i][j]=new White(this);
					setTypeSquare("White");
					this.squares[i][j].setPositionI(i);
					this.squares[i][j].setPositionJ(j);
				}
				else if(s.equals("G")){
					this.squares[i][j]=new Gray(this);
					setTypeSquare("Gray");
					this.squares[i][j].setPositionI(i);
					this.squares[i][j].setPositionJ(j);
				}
				else if(s.equals("C")){
					setTypeSquare("Circle");
					circle=new Circle(this);
					this.squares[i][j]=circle;
					this.squares[i][j].setPositionI(i);
					this.squares[i][j].setPositionJ(j);
				}
				else if(s.equals("S")){
					setTypeSquare("StartSquare");
					this.squares[i][j]=new StartSquare(this);
					this.squares[i][j].setPositionI(i);
					this.squares[i][j].setPositionJ(j);
				}
				else if(s.equals("E")){
					setTypeSquare("EndSquare");
					EndSquare es=new EndSquare(this);
					this.squares[i][j]=es;
					es.setCounters(new Treasure(getBoard().getBag()));
					this.squares[i][j].setPositionI(i);
					this.squares[i][j].setPositionJ(j);
					
				}

			}
		}

	}

	@Override
	public void setTotalNumberTiles(int totalNumberTiles) {
		// TODO Auto-generated method stub

	}

	@Override
	public void setTreasure(Treasure treasure) {
		// TODO Auto-generated method stub

	}

	@Override
	public void setTypeSquare(String typeSquare) {
		// TODO Auto-generated method stub

	}

	@Override
	public boolean thereIsGemInTile() {
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	public void addAdjacentTile(ITile tile, Integer i, Integer j) {
		// TODO Auto-generated method stub
		
	}

}
